﻿using System;
using System.Collections.Generic;
using System.Text;

namespace IceDog.DNL.CSharp.DesignPattern.FactoryPattern.WorldShape
{
    /// <summary>
    /// 图形类型
    /// </summary>
    public enum ShapeType
    {
        Circle,
        Rectangle,
        Square
    }

    /// <summary>
    /// 图形工厂
    /// </summary>
    public class ShapeFactory
    {
        //使用 getShape 方法获取形状类型的对象
        public IShapeAction GetShape(ShapeType type)
        {
            switch (type)
            {
                case ShapeType.Circle:
                    return new Circle();
                case ShapeType.Square:
                    return new Square();
                case ShapeType.Rectangle:
                    return new Rectangle();
                default:
                    return null;
            }
        }
    }
}

